using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Decisions.HL7.Message;
using DecisionsFramework;

namespace Decisions.HL7.Message
{
    public class KindofQuantityAttribute:RuleAttribute
    {
        private Dictionary<HL7Version, string[]> validVersionCodes = new Dictionary<HL7Version, string[]>();
        private Dictionary<HL7Version, string[]> validVersionDescriptions = new Dictionary<HL7Version, string[]>();
        private Dictionary<HL7Version, HL7TableType> tableVersionTypes = new Dictionary<HL7Version, HL7TableType>();

        public KindofQuantityAttribute()
        {
            // init the values for table version types
						tableVersionTypes[HL7Version.v23] = HL7TableType.HL7;
						tableVersionTypes[HL7Version.v231] = HL7TableType.HL7;
						tableVersionTypes[HL7Version.v24] = HL7TableType.HL7;
						tableVersionTypes[HL7Version.v25] = HL7TableType.HL7;
						tableVersionTypes[HL7Version.v251] = HL7TableType.HL7;
						tableVersionTypes[HL7Version.v26] = HL7TableType.HL7;
						tableVersionTypes[HL7Version.v27] = HL7TableType.HL7;
			
            
			// init the values for version codes
						validVersionCodes[HL7Version.v23] = new string[]{""};
						validVersionCodes[HL7Version.v231] = new string[]{"CACT","CNC","CCRTO","CCNT","CFR","CRAT","CRTO","ENT","ENTSUB","ENTCAT","ENTNUM","ENTVOL","MASS","MCNC","MCRTO","MCNT","MFR","MINC","MRAT","MRTO","NUM","NCNC","NCNT","NFR","NRTO","SUB","SCNC","SCRTO","SCNT","SCNTR","SFR","SCNCIN","SRAT","SRTO","VOL","VCNT","VFR","VRAT","VRTO","ACNC","RLMCNC","RLSCNC","THRMCNC","THRSCNC","TIME","TMDF","TMSTP","TRTO","RCRLTM","RLTM","ABS","ACT","APER","ARB","AREA","ASPECT","CLAS","CNST","COEF","COLOR","CONS","DEN","DEV","DIFF","ELAS","ELPOT","ELRAT","ELRES","ENGR","EQL","FORCE","FREQ","IMP","KINV","LEN","LINC","LIQ","MGFLUX","MORPH","MOTIL","OD","OSMOL","PRID","PRES","PWR","RANGE","RATIO","RDEN","REL","SATFR","SHAPE","SMELL","SUSC","TASTE","TEMP","TEMPDF","TEMPIN","TITR","TYPE","VEL","VELRT","VISC"};
						validVersionCodes[HL7Version.v24] = new string[]{"CACT","CNC","CCRTO","CCNT","CFR","CRAT","CRTO","ENT","ENTSUB","ENTCAT","ENTNUM","ENTVOL","MASS","MCNC","MCRTO","MCNT","MFR","MINC","MRAT","MRTO","NUM","NCNC","NCNT","NFR","NRTO","SUB","SCNC","SCRTO","SCNT","SCNTR","SFR","SCNCIN","SRAT","SRTO","VOL","VCNT","VFR","VRAT","VRTO","ACNC","RLMCNC","RLSCNC","THRMCNC","THRSCNC","TIME","TMDF","TMSTP","TRTO","RCRLTM","RLTM","ABS","ACT","APER","ARB","AREA","ASPECT","CLAS","CNST","COEF","COLOR","CONS","DEN","DEV","DIFF","ELAS","ELPOT","ELRAT","ELRES","ENGR","EQL","FORCE","FREQ","IMP","KINV","LEN","LINC","LIQ","MGFLUX","MORPH","MOTIL","OD","OSMOL","PRID","PRES","PWR","RANGE","RATIO","RDEN","REL","SATFR","SHAPE","SMELL","SUSC","TASTE","TEMP","TEMPDF","TEMPIN","TITR","TYPE","VEL","VELRT","VISC"};
						validVersionCodes[HL7Version.v25] = new string[]{"CACT","CNC","CCRTO","CCNT","CFR","CRAT","CRTO","ENT","ENTSUB","ENTCAT","ENTNUM","ENTVOL","MASS","MCNC","MCRTO","MCNT","MFR","MINC","MRAT","MRTO","NUM","NCNC","NCNT","NFR","NRTO","SUB","SCNC","SCRTO","SCNT","SCNTR","SFR","SCNCIN","SRAT","SRTO","VOL","VCNT","VFR","VRAT","VRTO","ACNC","RLMCNC","RLSCNC","THRMCNC","THRSCNC","TIME","TMDF","TMSTP","TRTO","RCRLTM","RLTM","ABS","ACT","APER","ARB","AREA","ASPECT","CLAS","CNST","COEF","COLOR","CONS","DEN","DEV","DIFF","ELAS","ELPOT","ELRAT","ELRES","ENGR","EQL","FORCE","FREQ","IMP","KINV","LEN","LINC","LIQ","MGFLUX","MORPH","MOTIL","OD","OSMOL","PRID","PRES","PWR","RANGE","RATIO","RDEN","REL","SATFR","SHAPE","SMELL","SUSC","TASTE","TEMP","TEMPDF","TEMPIN","TITR","TYPE","VEL","VELRT","VISC"};
						validVersionCodes[HL7Version.v251] = new string[]{"CACT","CNC","CCRTO","CCNT","CFR","CRAT","CRTO","ENT","ENTSUB","ENTCAT","ENTNUM","ENTVOL","MASS","MCNC","MCRTO","MCNT","MFR","MINC","MRAT","MRTO","NUM","NCNC","NCNT","NFR","NRTO","SUB","SCNC","SCRTO","SCNT","SCNTR","SFR","SCNCIN","SRAT","SRTO","VOL","VCNT","VFR","VRAT","VRTO","ACNC","RLMCNC","RLSCNC","THRMCNC","THRSCNC","TIME","TMDF","TMSTP","TRTO","RCRLTM","RLTM","ABS","ACT","APER","ARB","AREA","ASPECT","CLAS","CNST","COEF","COLOR","CONS","DEN","DEV","DIFF","ELAS","ELPOT","ELRAT","ELRES","ENGR","EQL","FORCE","FREQ","IMP","KINV","LEN","LINC","LIQ","MGFLUX","MORPH","MOTIL","OD","OSMOL","PRID","PRES","PWR","RANGE","RATIO","RDEN","REL","SATFR","SHAPE","SMELL","SUSC","TASTE","TEMP","TEMPDF","TEMPIN","TITR","TYPE","VEL","VELRT","VISC"};
						validVersionCodes[HL7Version.v26] = new string[]{"CACT","CNC","CCRTO","CCNT","CFR","CRAT","CRTO","ENT","ENTSUB","ENTCAT","ENTNUM","ENTVOL","MASS","MCNC","MCRTO","MCNT","MFR","MINC","MRAT","MRTO","NUM","NCNC","NCNT","NFR","NRTO","SUB","SCNC","SCRTO","SCNT","SCNTR","SFR","SCNCIN","SRAT","SRTO","VOL","VCNT","VFR","VRAT","VRTO","ACNC","RLMCNC","RLSCNC","THRMCNC","THRSCNC","TIME","TMDF","TMSTP","TRTO","RCRLTM","RLTM","ABS","ACT","APER","ARB","AREA","ASPECT","CLAS","CNST","COEF","COLOR","CONS","DEN","DEV","DIFF","ELAS","ELPOT","ELRAT","ELRES","ENGR","EQL","FORCE","FREQ","IMP","KINV","LEN","LINC","LIQ","MGFLUX","MORPH","MOTIL","OD","OSMOL","PRID","PRES","PWR","RANGE","RATIO","RDEN","REL","SATFR","SHAPE","SMELL","SUSC","TASTE","TEMP","TEMPDF","TEMPIN","TITR","TYPE","VEL","VELRT","VISC"};
						validVersionCodes[HL7Version.v27] = new string[]{"CACT","CNC","CCRTO","CCNT","CFR","CRAT","CRTO","ENT","ENTSUB","ENTCAT","ENTNUM","ENTVOL","MASS","MCNC","MCRTO","MCNT","MFR","MINC","MRAT","MRTO","NUM","NCNC","NCNT","NFR","NRTO","SUB","SCNC","SCRTO","SCNT","SCNTR","SFR","SCNCIN","SRAT","SRTO","VOL","VCNT","VFR","VRAT","VRTO","ACNC","RLMCNC","RLSCNC","THRMCNC","THRSCNC","TIME","TMDF","TMSTP","TRTO","RCRLTM","RLTM","ABS","ACT","APER","ARB","AREA","ASPECT","CLAS","CNST","COEF","COLOR","CONS","DEN","DEV","DIFF","ELAS","ELPOT","ELRAT","ELRES","ENGR","EQL","FORCE","FREQ","IMP","KINV","LEN","LINC","LIQ","MGFLUX","MORPH","MOTIL","OD","OSMOL","PRID","PRES","PWR","RANGE","RATIO","RDEN","REL","SATFR","SHAPE","SMELL","SUSC","TASTE","TEMP","TEMPDF","TEMPIN","TITR","TYPE","VEL","VELRT","VISC"};
			
			// init the values for version descriptions
						validVersionDescriptions[HL7Version.v23] = new string[]{""};
						validVersionDescriptions[HL7Version.v231] = new string[]{"*Catalytic Activity","*Catalytic Concentration","Catalytic Concentration Ratio","*Catalytic Content","*Catalytic Fraction","*Catalytic Rate","Catalytic Ratio","*Entitic","*Entitic Substance of Amount","*Entitic Catalytic Activity","*Entitic Number","*Entitic Volume","*Mass","*Mass Concentration","*Mass Concentration Ratio","Mass Content","*Mass Fraction","*Mass Increment","*Mass Rate","*Mass Ratio","*Number","*Number Concentration","*Number Content","*Number Fraction","*Number Ratio","*Substance Amount","*Substance Concentration","*Substance Concentration Ratio","*Substance Content","*Substance Content Rate","*Substance Fraction","*Substance Concentration Increment","*Substance Rate","*Substance Ratio","*Volume","*Volume Content","*Volume Fraction","*Volume Rate","*Volume Ratio","Concentration, Arbitrary Substance","*Relative Mass Concentration","*Relative Substance Concentration","*Threshold Mass Concentration","*Threshold Substance Concentration","*Time (e.g. seconds)","*Time Difference","*Time Stamp -- Date and Time","*Time Ratio","*Reciprocal Relative Time","*Relative Time","Absorbance","*Activity","Appearance","*Arbitrary","Area","Aspect","Class","*Constant","*Coefficient","Color","Consistency","Density","Device","*Difference","Elasticity","Electrical Potential (Voltage)","Electrical current (amperage)","Electrical Resistance","Energy","Equilibrium","Mechanical force","Frequency","Impression/ interpretation of study","*Kinematic Viscosity","Length","*Length Increment","*Liquifaction","Magnetic flux","Morphology","Motility","Optical density","*Osmolality","Presence/Identity/Existence","*Pressure (Partial)","Power (wattage)","*Ranges","*Ratios","*Relative Density","*Relative","*Saturation Fraction","Shape","Smell","*Susceptibility","Taste","*Temperature","*Temperature Difference","*Temperature Increment","*Dilution Factor (Titer)","*Type","*Velocity","*Velocity Ratio","*Viscosity"};
						validVersionDescriptions[HL7Version.v24] = new string[]{"*Catalytic Activity","*Catalytic Concentration","Catalytic Concentration Ratio","*Catalytic Content","*Catalytic Fraction","*Catalytic Rate","Catalytic Ratio","*Entitic","*Entitic Substance of Amount","*Entitic Catalytic Activity","*Entitic Number","*Entitic Volume","*Mass","*Mass Concentration","*Mass Concentration Ratio","Mass Content","*Mass Fraction","*Mass Increment","*Mass Rate","*Mass Ratio","*Number","*Number Concentration","*Number Content","*Number Fraction","*Number Ratio","*Substance Amount","*Substance Concentration","*Substance Concentration Ratio","*Substance Content","*Substance Content Rate","*Substance Fraction","*Substance Concentration Increment","*Substance Rate","*Substance Ratio","*Volume","*Volume Content","*Volume Fraction","*Volume Rate","*Volume Ratio","Concentration, Arbitrary Substance","*Relative Mass Concentration","*Relative Substance Concentration","*Threshold Mass Concentration","*Threshold Substance Concentration","*Time (e.g. seconds)","*Time Difference","*Time Stamp -- Date and Time","*Time Ratio","*Reciprocal Relative Time","*Relative Time","Absorbance","*Activity","Appearance","*Arbitrary","Area","Aspect","Class","*Constant","*Coefficient","Color","Consistency","Density","Device","*Difference","Elasticity","Electrical Potential (Voltage)","Electrical current (amperage)","Electrical Resistance","Energy","Equilibrium","Mechanical force","Frequency","Impression/ interpretation of study","*Kinematic Viscosity","Length","*Length Increment","*Liquefaction","Magnetic flux","Morphology","Motility","Optical density","*Osmolality","Presence/Identity/Existence","*Pressure (Partial)","Power (wattage)","*Ranges","*Ratios","*Relative Density","*Relative","*Saturation Fraction","Shape","Smell","*Susceptibility","Taste","*Temperature","*Temperature Difference","*Temperature Increment","*Dilution Factor (Titer)","*Type","*Velocity","*Velocity Ratio","*Viscosity"};
						validVersionDescriptions[HL7Version.v25] = new string[]{"*Catalytic Activity","*Catalytic Concentration","Catalytic Concentration Ratio","*Catalytic Content","*Catalytic Fraction","*Catalytic Rate","Catalytic Ratio","*Entitic","*Entitic Substance of Amount","*Entitic Catalytic Activity","*Entitic Number","*Entitic Volume","*Mass","*Mass Concentration","*Mass Concentration Ratio","Mass Content","*Mass Fraction","*Mass Increment","*Mass Rate","*Mass Ratio","*Number","*Number Concentration","*Number Content","*Number Fraction","*Number Ratio","*Substance Amount","*Substance Concentration","*Substance Concentration Ratio","*Substance Content","*Substance Content Rate","*Substance Fraction","*Substance Concentration Increment","*Substance Rate","*Substance Ratio","*Volume","*Volume Content","*Volume Fraction","*Volume Rate","*Volume Ratio","Concentration, Arbitrary Substance","*Relative Mass Concentration","*Relative Substance Concentration","*Threshold Mass Concentration","*Threshold Substance Concentration","*Time (e.g. seconds)","*Time Difference","*Time Stamp -- Date and Time","*Time Ratio","*Reciprocal Relative Time","*Relative Time","Absorbance","*Activity","Appearance","*Arbitrary","Area","Aspect","Class","*Constant","*Coefficient","Color","Consistency","Density","Device","*Difference","Elasticity","Electrical Potential (Voltage)","Electrical current (amperage)","Electrical Resistance","Energy","Equilibrium","Mechanical force","Frequency","Impression/ interpretation of study","*Kinematic Viscosity","Length","*Length Increment","*Liquefaction","Magnetic flux","Morphology","Motility","Optical density","*Osmolality","Presence/Identity/Existence","*Pressure (Partial)","Power (wattage)","*Ranges","*Ratios","*Relative Density","*Relative","*Saturation Fraction","Shape","Smell","*Susceptibility","Taste","*Temperature","*Temperature Difference","*Temperature Increment","*Dilution Factor (Titer)","*Type","*Velocity","*Velocity Ratio","*Viscosity"};
						validVersionDescriptions[HL7Version.v251] = new string[]{"*Catalytic Activity","*Catalytic Concentration","Catalytic Concentration Ratio","*Catalytic Content","*Catalytic Fraction","*Catalytic Rate","Catalytic Ratio","*Entitic","*Entitic Substance of Amount","*Entitic Catalytic Activity","*Entitic Number","*Entitic Volume","*Mass","*Mass Concentration","*Mass Concentration Ratio","Mass Content","*Mass Fraction","*Mass Increment","*Mass Rate","*Mass Ratio","*Number","*Number Concentration","*Number Content","*Number Fraction","*Number Ratio","*Substance Amount","*Substance Concentration","*Substance Concentration Ratio","*Substance Content","*Substance Content Rate","*Substance Fraction","*Substance Concentration Increment","*Substance Rate","*Substance Ratio","*Volume","*Volume Content","*Volume Fraction","*Volume Rate","*Volume Ratio","Concentration, Arbitrary Substance","*Relative Mass Concentration","*Relative Substance Concentration","*Threshold Mass Concentration","*Threshold Substance Concentration","*Time (e.g. seconds)","*Time Difference","*Time Stamp -- Date and Time","*Time Ratio","*Reciprocal Relative Time","*Relative Time","Absorbance","*Activity","Appearance","*Arbitrary","Area","Aspect","Class","*Constant","*Coefficient","Color","Consistency","Density","Device","*Difference","Elasticity","Electrical Potential (Voltage)","Electrical current (amperage)","Electrical Resistance","Energy","Equilibrium","Mechanical force","Frequency","Impression/ interpretation of study","*Kinematic Viscosity","Length","*Length Increment","*Liquefaction","Magnetic flux","Morphology","Motility","Optical density","*Osmolality","Presence/Identity/Existence","*Pressure (Partial)","Power (wattage)","*Ranges","*Ratios","*Relative Density","*Relative","*Saturation Fraction","Shape","Smell","*Susceptibility","Taste","*Temperature","*Temperature Difference","*Temperature Increment","*Dilution Factor (Titer)","*Type","*Velocity","*Velocity Ratio","*Viscosity"};
						validVersionDescriptions[HL7Version.v26] = new string[]{"*Catalytic Activity","*Catalytic Concentration","Catalytic Concentration Ratio","*Catalytic Content","*Catalytic Fraction","*Catalytic Rate","Catalytic Ratio","*Entitic","*Entitic Substance of Amount","*Entitic Catalytic Activity","*Entitic Number","*Entitic Volume","*Mass","*Mass Concentration","*Mass Concentration Ratio","Mass Content","*Mass Fraction","*Mass Increment","*Mass Rate","*Mass Ratio","*Number","*Number Concentration","*Number Content","*Number Fraction","*Number Ratio","*Substance Amount","*Substance Concentration","*Substance Concentration Ratio","*Substance Content","*Substance Content Rate","*Substance Fraction","*Substance Concentration Increment","*Substance Rate","*Substance Ratio","*Volume","*Volume Content","*Volume Fraction","*Volume Rate","*Volume Ratio","Concentration, Arbitrary Substance","*Relative Mass Concentration","*Relative Substance Concentration","*Threshold Mass Concentration","*Threshold Substance Concentration","*Time (e.g. seconds)","*Time Difference","*Time Stamp-Date and Time","*Time Ratio","*Reciprocal Relative Time","*Relative Time","Absorbance","*Activity","Appearance","*Arbitrary","Area","Aspect","Class","*Constant","*Coefficient","Color","Consistency","Density","Device","*Difference","Elasticity","Electrical Potential (Voltage)","Electrical current (amperage)","Electrical Resistance","Energy","Equilibrium","Mechanical force","Frequency","Impression/ interpretation of study","*Kinematic Viscosity","Length","*Length Increment","*Liquefaction","Magnetic flux","Morphology","Motility","Optical density","*Osmolality","Presence/Identity/Existence","*Pressure (Partial)","Power (wattage)","*Ranges","*Ratios","*Relative Density","*Relative","*Saturation Fraction","Shape","Smell","*Susceptibility","Taste","*Temperature","*Temperature Difference","*Temperature Increment","*Dilution Factor (Titer)","*Type","*Velocity","*Velocity Ratio","*Viscosity"};
						validVersionDescriptions[HL7Version.v27] = new string[]{"*Catalytic Activity","*Catalytic Concentration","Catalytic Concentration Ratio","*Catalytic Content","*Catalytic Fraction","*Catalytic Rate","Catalytic Ratio","*Entitic","*Entitic Substance of Amount","*Entitic Catalytic Activity","*Entitic Number","*Entitic Volume","*Mass","*Mass Concentration","*Mass Concentration Ratio","Mass Content","*Mass Fraction","*Mass Increment","*Mass Rate","*Mass Ratio","*Number","*Number Concentration","*Number Content","*Number Fraction","*Number Ratio","*Substance Amount","*Substance Concentration","*Substance Concentration Ratio","*Substance Content","*Substance Content Rate","*Substance Fraction","*Substance Concentration Increment","*Substance Rate","*Substance Ratio","*Volume","*Volume Content","*Volume Fraction","*Volume Rate","*Volume Ratio","Concentration, Arbitrary Substance","*Relative Mass Concentration","*Relative Substance Concentration","*Threshold Mass Concentration","*Threshold Substance Concentration","*Time (e.g. seconds)","*Time Difference","*Time Stamp-Date and Time","*Time Ratio","*Reciprocal Relative Time","*Relative Time","Absorbance","*Activity","Appearance","*Arbitrary","Area","Aspect","Class","*Constant","*Coefficient","Color","Consistency","Density","Device","*Difference","Elasticity","Electrical Potential (Voltage)","Electrical current (amperage)","Electrical Resistance","Energy","Equilibrium","Mechanical force","Frequency","Impression/ interpretation of study","*Kinematic Viscosity","Length","*Length Increment","*Liquefaction","Magnetic flux","Morphology","Motility","Optical density","*Osmolality","Presence/Identity/Existence","*Pressure (Partial)","Power (wattage)","*Ranges","*Ratios","*Relative Density","*Relative","*Saturation Fraction","Shape","Smell","*Susceptibility","Taste","*Temperature","*Temperature Difference","*Temperature Increment","*Dilution Factor (Titer)","*Type","*Velocity","*Velocity Ratio","*Viscosity"};
			            

        }

        
        public override ValidationIssue[] RunRule(string name, object owningObject, object value)
        {
            //todo: check if the value is valid in the current version
            //if the value is not valid in the current version, add it as a validation issue


            return new ValidationIssue[0];
        }
    }
}
